import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { configParams } from '../storage-config';

@Injectable({
  providedIn: 'root'
})
export class StorageManageStockService {

  headers = configParams.headers;

  serviceUrls: any = {
    queryStockWarehouseListUrl: '/stock/listWh', // 库存查询(仓库)
    exportStockWarehouseUrl: '/stock/listWhExcel', // 库存查询(仓库) -- 导出
    queryStockLocationListUrl: '/stock/list', // 库存查询(库位)
    exportStockLocationUrl: '/stock/findExcel', // 库存查询(库位) -- 导出
    querySncodeListUrl: '/sn/list', // SN码信息查询
    exportSncodeUrl: '/sn/findExcel', // SN码信息 -- 导出
    queryStockmxUrl: '/goodsOperationDetails/list', // 商品出入库明细查询
    exportStockmxUrl: '/goodsOperationDetails/findExcel', // 商品出入库明细 -- 导出
  };

  constructor(public httpClient: HttpClient) { }

  /**
   * ----------------------------------------------------------------
   * ****** 库存查询（仓库）******
   * ----------------------------------------------------------------
   */
  // 库存查询（仓库）
  getStockWarehouseList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryStockWarehouseListUrl, params, {headers: this.headers}).toPromise();
  }

  // 库存查询（仓库）导出
  exportStockWarehouse(params: any) {
    return this.httpClient.get(this.serviceUrls.exportStockWarehouseUrl, {params, responseType: 'blob', headers: this.headers}).toPromise();
  }
  
  /**
   * ----------------------------------------------------------------
   * ****** 库存查询（库位）******
   * ----------------------------------------------------------------
   */

  // 库存查询（库位）
  getStockLocationList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryStockLocationListUrl, params, {headers: this.headers}).toPromise();
  }

  // 库存查询（库位）导出
  exportStockLocation(params: any) {
    return this.httpClient.get(this.serviceUrls.exportStockLocationUrl, {params, responseType: 'blob', headers: this.headers}).toPromise();
  }

  /**
   * ----------------------------------------------------------------
   * ****** SN码信息 ******
   * ----------------------------------------------------------------
   */
  // SN码信息 查询
  getSncodeList(params: any) {
    return this.httpClient.post(this.serviceUrls.querySncodeListUrl, params, {headers: this.headers}).toPromise();
  }

  // SN码信息 导出
  exportSncodeData(params: any) {
    return this.httpClient.get(this.serviceUrls.exportSncodeUrl, {params, responseType: 'blob', headers: this.headers}).toPromise();
  }

  /**
   * ----------------------------------------------------------------
   * ****** 商品出入库明细 ******
   * ----------------------------------------------------------------
   */
  // 商品出入库明细 查询
  getStockmxData(params: any) {
    return this.httpClient.post(this.serviceUrls.queryStockmxUrl, params, {headers: this.headers}).toPromise();
  }

  // 商品出入库明细 导出
  exportStockmxData(params: any) {
    return this.httpClient.get(this.serviceUrls.exportStockmxUrl, {params, responseType: 'blob', headers: this.headers}).toPromise();
  }
}



